'''
使用web方式执行dos指令

参考:
https://www.cnblogs.com/qican/p/11468866.html
'''

from flask import Flask, render_template, request
import os

app = Flask(__name__)


@app.route('/')
def index():
    return render_template('index.html')


@app.route('/dotest', methods=['post'])
def dotest():
    cmds = request.form.get('cmds')
    d = os.popen(cmds)  # 执行dos命令
    f = d.read()  # 读取执行结果
    print(f)  # 在控制台输出结果
    return render_template('index.html')


if __name__ == '__main__':
    app.run(debug=True)
